package com.debao.web.controller.debao;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.debao.common.annotation.Log;
import com.debao.common.core.controller.BaseController;
import com.debao.common.core.domain.AjaxResult;
import com.debao.common.enums.BusinessType;
import com.debao.system.domain.StadiumTableOrder;
import com.debao.system.service.IStadiumTableOrderService;
import com.debao.common.utils.poi.ExcelUtil;
import com.debao.common.core.page.TableDataInfo;

/**
 * 预订场馆的订单Controller
 * 
 * @author DeBao
 * @date 2024-07-08
 */
@RestController
@RequestMapping("/debao/stadiumTableOrder")
public class StadiumTableOrderController extends BaseController
{
    @Autowired
    private IStadiumTableOrderService stadiumTableOrderService;

    /**
     * 查询预订场馆的订单列表
     */
    @PreAuthorize("@ss.hasPermi('debao:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(StadiumTableOrder stadiumTableOrder)
    {
        startPage();
        List<StadiumTableOrder> list = stadiumTableOrderService.selectStadiumTableOrderList(stadiumTableOrder);
        return getDataTable(list);
    }

    /**
     * 导出预订场馆的订单列表
     */
    @PreAuthorize("@ss.hasPermi('debao:order:export')")
    @Log(title = "预订场馆的订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StadiumTableOrder stadiumTableOrder)
    {
        List<StadiumTableOrder> list = stadiumTableOrderService.selectStadiumTableOrderList(stadiumTableOrder);
        ExcelUtil<StadiumTableOrder> util = new ExcelUtil<StadiumTableOrder>(StadiumTableOrder.class);
        util.exportExcel(response, list, "预订场馆的订单数据");
    }

    /**
     * 获取预订场馆的订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('debao:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(stadiumTableOrderService.selectStadiumTableOrderById(id));
    }

    /**
     * 新增预订场馆的订单
     */
    @PreAuthorize("@ss.hasPermi('debao:order:add')")
    @Log(title = "预订场馆的订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StadiumTableOrder stadiumTableOrder)
    {
        return toAjax(stadiumTableOrderService.insertStadiumTableOrder(stadiumTableOrder));
    }

    /**
     * 修改预订场馆的订单
     */
    @PreAuthorize("@ss.hasPermi('debao:order:edit')")
    @Log(title = "预订场馆的订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StadiumTableOrder stadiumTableOrder)
    {
        return toAjax(stadiumTableOrderService.updateStadiumTableOrder(stadiumTableOrder));
    }

    /**
     * 删除预订场馆的订单
     */
    @PreAuthorize("@ss.hasPermi('debao:order:remove')")
    @Log(title = "预订场馆的订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stadiumTableOrderService.deleteStadiumTableOrderByIds(ids));
    }
}
